<?php $this->placeholder('container-class')->set('post_ad detail property residential')?>
<?php $this->JQuery()->javascriptCaptureStart()?>
jQuery(function() {
    $('#agency_owner-1').click(function() {
        $('#agentname_label').show();
        $('#agentphone_label').show();
        $('#agentmail_label').show();
        $('#id_input_agent').show();
        $('#sole_agency_label').show();
        
        $('#ownername_label').hide();
        $('#ownerphone_label').hide();
        $('#ownermail_label').hide();
    });

    $('#agency_owner-0').click(function() {
        $('#agentname_label').hide();
        $('#agentphone_label').hide();
        $('#agentmail_label').hide();
        $('#id_input_agent').hide();photos
        $('#sole_agency_label').hide();

        $('#ownername_label').show();
        $('#ownerphone_label').show();
        $('#ownermail_label').show();
    });

    $('#add_more_btn').click(function() {               
        if ($('#add_more_checkbox').attr('value') == 1) {
            $('#add_more_checkbox').attr('value',0);
        }
        else {
            $('#add_more_checkbox').attr('value',1);
        }
        $('#add_more').toggle();
        return false;
    });

    $('#sale_lease').click(function() {
        $('#sale_lease_panel').toggle();
    });

    $('#rent_property_too').click(function() {
        $('#rent_property_too_panel').toggle();
    });
    
    if ($('#sale_lease:checked').val() == 1) {
        $('#sale_lease_panel').show();
    }
    else {
        $('#sale_lease_panel').hide();
    }

    if ($('#add_more_checkbox').attr('value') == 0) {
        $('#add_more').show();
    }
    else {
        $('#add_more').hide();
    }

    // Control for Title
    $('input#tl_en').keydown(function(event) {
        var charLength = 100 - $(this).val().length;
        if (charLength <0) {
            if ( event.keyCode == 8 || event.keyCode == 46 ) {

            } else {
                return false;
            }
        }
        else {
            $('span.counter_title').html('剩余<em>'+charLength + '</em>字');
        }
    });

    // Control for Description
    $('textarea#cs_en').keydown(function(event) {
        var charLength = 3000 - $(this).val().length;
        if (charLength <0) {
            if ( event.keyCode == 8 || event.keyCode == 46 ) {

            } else {
                return false;
            }
        }
        else {
            $('span.counter_description').html('还可以输入<em>'+charLength + '</em>字；为避免收到垃圾邮件，请勿输入邮箱地址');
        }
    });

    //Online Only Area
    if ($j("#area_l1").val() == "4cbe455a8835c17c10060000") {
        $j("#district_div").hide();
    }
    else {
        $j("#district_div").show();
    }


    $j('#preview_link').click(function() {
        var action = $j('#listing_form').attr('action');
        $j('#listing_form').attr('action', '<?php echo $this->preview_link?>');
        $j('#listing_form').attr('target','_blank');
        $j('#listing_form').submit();
        $j('#listing_form').attr('action', action);
        $j('#listing_form').attr('target','_self');
        return false;
    });
    
    $j('.direction: br').remove();
});
<?php $this->JQuery()->javascriptCaptureEnd()?>
<?php $this->headStyle()->captureStart()?>
.direction{}
.direction br{display:none:}
<?php $this->headStyle()->captureEnd()?>
<?php $errors = $this->form->getErrors(); //print_r($errors);?>

<form action="<?php echo $this->escape($this->form->getAction()) ?>" method="<?php echo $this->escape($this->form->getMethod())?>" id="listing_form"  enctype="multipart/form-data">
	<fieldset class="info">
		<legend>描述</legend>
		<div class="required"><span class="required">*</span>必须填写</div>
		<div class="category desc">
			<label>已选分类</label>
			<ul>
				<?php foreach($this->category as $cat):?>
                <li>
                  <?php 
                    $tmp = array();
                    foreach($cat->getParentTree() as $p) {
                        $tmp[] = $p->name;
                    }
                    echo implode(' &gt; ', $tmp);
                  ?>
                </li>
              	<?php endforeach;?>
			</ul>
		</div>
		<input type="hidden" name="adid" id="adid" value="<?php echo $this->adid?>">
        <?php foreach($this->category as $cat):?>
            <input type="hidden" name="category[]" value="<?php echo $cat->_id?>">
        <?php endforeach;?>
		<div class="title text">
          	<label><span class="required">*</span>信息标题</label>
          	<?php echo $this->form->tl_en ?> 
          	<span class="remark counter_title">剩余<em>100</em>字</span>
          	<?php if (!empty($_POST['tl_en'])): ?>
              	<?php if (preg_match("#.[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}.#", $_POST['tl_en'])): ?>
                  	<ul class="errors"><li><?php echo $this->t('请勿输入邮箱地址')?></li></ul>
              	<?php endif;?>
          	<?php endif; ?>
          	<?php if(!empty($errors['tl_en'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->tl_en->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          	<?php endif;?> 
        </div>
		<div class="price_section section">
			<div class="desc">
				<h4><span class="required">*</span>售价或租价</h4>
				<p>请至少输入一项<em>售价</em>或<em>租价</em></p>
			</div>
			<div class="price sell text unit">
				<label>售价</label>
				<?php echo $this->form->sale_price ?>
				<span class="unit">元</span><span class="remark">请填写数字</span> 
				<?php if (isset($_POST['rent_price']) && empty($_POST['sale_price']) && empty($_POST['rent_price'])): ?>
	                <ul class="errors"><li><?php echo $this->t('请填写售价或租价')?></li></ul>
	          	<?php endif; ?>
				<?php if(!empty($errors['sale_price'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->sale_price->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          		<?php endif;?> 
			</div>
			<div class="price rent text unit col6">
				<label>租价</label>
				<?php echo $this->form->rent_price ?>
				<span class="unit">元</span><span class="remark">请填写数字</span> 
				<?php if (isset($_POST['rent_price']) && empty($_POST['rent_price']) && empty($_POST['sale_price'])): ?>
	                <ul class="errors"><li><?php echo $this->t('请填写售价或租价')?></li></ul>
	          	<?php endif; ?>
				<?php if(!empty($errors['rent_price'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->rent_price->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          		<?php endif;?> 
			</div>
			<div class="rent select col6"> 
				<label>出租方式</label>
				<?php echo $this->form->rent_type ?>
				<?php if(!empty($errors['rent_type'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->rent_type->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          		<?php endif;?> 
			</div>
		</div>
		<div class="bedroom text col4 unit">
			<label>卧室</label>
			<?php echo $this->form->bedroom ?>
		</div>
		<div class="living_room text col4 unit">
			<label>厅</label>
			<?php echo $this->form->other_room ?>
		</div>
		<div class="toilet text col4 unit">
			<label>卫生间</label>
			<?php echo $this->form->bathroom ?>
		</div>
		<div class="renovation select col6">
			<label>装修情况</label>
			<?php echo $this->form->renovation ?>
			<?php if(!empty($errors['which_floor'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->renovation->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          		<?php endif;?> 
		</div>
		<div class="floor text col6 unit">
			<label>所在楼层</label>
			<?php echo $this->form->which_floor ?>
			<span class="unit">楼</span><span class="remark">请填写数字</span> 
			<?php if(!empty($errors['which_floor'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->which_floor->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          		<?php endif;?> 
		</div>
		<div class="floor_all text col6 unit">
			<label>共有层数</label>
			<?php echo $this->form->total_floor ?>
			<span class="unit">层</span><span class="remark">请填写数字</span> 
			<?php if(!empty($errors['total_floor'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->total_floor->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          		<?php endif;?> 
		</div>          
		<div class="flat_year text unit col6">
			<label>房龄</label>
			<?php echo $this->form->age?>
			<span class="unit">年</span><span class="remark">请填写数字</span> 
			<?php if(!empty($errors['age'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->age->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          		<?php endif;?> 
		</div>
		<div class="gross floor area text unit col6">
            <label class="required">建筑面积</label>
            <?php echo $this->form->total_size?>
            <span class="unit">平方米</span><span class="remark">请填写数字</span>
            <?php if(!empty($errors['total_size'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->total_size->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          		<?php endif;?> 
		</div>
        <div class="saleable area text unit col6">
            <label class="required">使用面积</label>
            <?php echo $this->form->size?>
            <span class="unit">平方米</span><span class="remark">请填写数字</span>
            <?php if(!empty($errors['size'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->size->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          		<?php endif;?> 
		</div>
		
		<div class="direction checkbox"> 
			<span>朝向</span>
			<?php echo $this->form->direction?>
		</div>
		<div class="textarea description">
            <label><span class="required">*</span>详述</label>
            <?php echo $this->form->cs_en?>
			<?php if (!empty($_POST['cs_en'])) { ?>
            <?php if (preg_match("#.[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}.#", $_POST['cs_en'])) { ?>
            	<ul class="errors"><li><?php echo $this->t('请勿输入邮箱地址')?></li></ul>
            <?php } } ?>
            <span class="remark counter_description">还可以输入<em>3000</em>字；为避免收到垃圾邮件，请勿输入邮箱地址</span> 
            <?php if(!empty($errors['cs_en'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->cs_en->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          		<?php endif;?> 
		</div>
		<div class="radio price">
			<span>发布地区</span>
			<?php foreach ($this->form->loc_flag->options as $k => $opt):?>
				<label>	
					<input type="radio" name="loc_flag" id="price-<?php echo $k?>" value="<?php echo $k?>" <?php echo $this->form->loc_flag->getValue() == $k ? 'checked' : ''?>>
					<?php echo $opt?>
				</label>
			<?php endforeach;?>
		</div>
		<div class="text complex">
			<label>所在小区</label>
			<?php echo $this->form->complex ?>
			<!--span class="remark">備註</span-->
		</div>
		<div class="select text address">
            <label><span class="required">*</span>地址</label>
            
            <?php echo $this->form->area_l1 ?>
			<?php echo $this->form->area_l2 ?>
			<?php echo $this->form->st_en ?>
			<span class="remark">请在下拉菜单选择一个选项，不能为空</span> 
			<?php if(!empty($errors['area_l1'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->area_l1->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          	<?php endif;?> 
          	<?php if(isset($_POST['area_l1']) && !empty($_POST['area_l1'])):?>
			<?php if(empty($_POST['area_l2']) && $_POST['area_l1']!=ENTIRE_CITY):?>
          		<ul class="errors">
				  	<li>请在下拉菜单选择一个选项，不能为空</li>
				</ul>
          	<?php endif;?> 
          	<?php endif;?> 
          	<?php if(!empty($errors['st_en'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->st_en->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          	<?php endif;?> 
		</div>
		<div class="tag text">
			<label>关键字</label>
			<?php echo $this->form->tag ?>
			<span class="remark">输入关键字有助于你的宝贝更容易被发现，各关键词请以逗号(，)分隔<br>
			(如：苹果，Apple，Iphone，32G)</span> 
		</div>
		<div class="remark text">
			<label>一句话描述</label>
			<?php echo $this->form->remark ?>
			<span class="remark">此描述会放在搜索结果及在本信息置顶，帮助买家更了解你的宝贝</span> 
		</div>
		<div class="contact_section section">
			<div class="desc">
				<h4>联络人资料</h4>
				<p>对你宝贝感兴趣的人应该联络谁</p>
			</div>
			<div class="contact_name text">
				<label>联系人</label>
				<?php echo $this->form->c_name ?>
				<span class="desc_checkbox"><?php echo $this->form->agent ?> 我是房产中介</span>
			</div>          
			<div class="tel text col6">
				<label>电话</label>
				<?php echo $this->form->c_tel ?>
			</div>
			<div class="msn_qq text col6">
				<label>MSN / QQ</label>
				<?php echo $this->form->c_msn ?>
			</div>
		</div>
	</fieldset>
	<fieldset class="photo">
        <legend>图片</legend>
        <?php echo $this->Partial('/index/photo-uploader.phtml', 'listing', array('listing' => $this->listing));?>
		<div class="action">

          	<div class="button back">
            	<a href="<?php echo $this->geturl('post-an-ad', 'listing', null, null, array('category' => $_GET['category'], 'change' => 1))?>">返回上一步</a>
            	<!--button type="submit">返回上一步</button-->
          	</div>
          	<div class="button em submit">
            	<button type="submit" name="postyourad">下一步</button>
          	</div>
          	<!--div class="button em">
	          <button type="submit" name="postyourad"><?php echo $this->t('Post Your Ad')?></button>
	        </div>
	        <div class="preview button">
	           <button id="review-your-ad" type="submit" name="review"><?php echo $this->t('Edit Translation')?></button>
	        </div-->
        </div>
	</fieldset>
</form>
